package org.hackystat.ambientdevice.trigger;

import java.util.logging.Logger;
import javax.xml.datatype.XMLGregorianCalendar;
import org.hackystat.ambientdevice.server.jaxb.Project;
import org.hackystat.ambientdevice.server.jaxb.Trigger;
import org.hackystat.utilities.logger.HackystatLogger;

/**
 * Interface for Trigger to perform its validation.
 * 
 * @author Shaoxuan Zhang
 * 
 */
public abstract class HackystatTrigger {

  private String id;
  /** the project to monitor. */
  private Project project;
  private String value = "";
  private Double maxValue;
  private Double minValue;
  private XMLGregorianCalendar lastUpdateTime = null;
  /** The logger for logging. */
  protected Logger logger = HackystatLogger.getLogger("org.hackystat.ambientdevice");

  /**
   * 
   * @param project the project
   * @param trigger the trigger for the project
   */
  public HackystatTrigger(Project project, Trigger trigger) {
    this.setProject(project);
    this.setId(trigger.getId());
    this.setMaxValue(trigger.getMaxValue());
    this.setMinValue(trigger.getMinValue());
    this.setValue(trigger.getValue());
  }

  /**
   * @return something?
   */
  public abstract boolean getState();

  /**
   * @param name the name to set
   */
  public final void setName(String name) {
    this.setId(name);
  }

  /**
   * @return the name
   */
  public final String getName() {
    return getId();
  }

  /**
   * @param value the value to set
   */
  public final void setValue(String value) {
    this.value = value;
  }

  /**
   * @return the value
   */
  public final String getValue() {
    return value;
  }

  /**
   * @param project the project to set
   */
  public final void setProject(Project project) {
    this.project = project;
  }

  /**
   * @return the project
   */
  public final Project getProject() {
    return project;
  }

  /**
   * @param lastUpdateTime the lastUpdateTime to set
   */
  public final void setLastUpdateTime(XMLGregorianCalendar lastUpdateTime) {
    this.lastUpdateTime = lastUpdateTime;
  }

  /**
   * @return the lastUpdateTime
   */
  public final XMLGregorianCalendar getLastUpdateTime() {
    return lastUpdateTime;
  }

  /**
   * @param maxValue the maxValue to set
   */
  public final void setMaxValue(Double maxValue) {
    this.maxValue = maxValue;
  }

  /**
   * @return the maxValue
   */
  public final Double getMaxValue() {
    return maxValue;
  }

  /**
   * @param minValue the minValue to set
   */
  public final void setMinValue(Double minValue) {
    this.minValue = minValue;
  }

  /**
   * @return the minValue
   */
  public final Double getMinValue() {
    return minValue;
  }

  /**
   * @param id the id to set
   */
  public final void setId(String id) {
    this.id = id;
  }

  /**
   * @return the id
   */
  public final String getId() {
    return id;
  }

}
